//
//  USInputCell.m
//  us
//
//  Created by karry on 2025/4/27.
//

#import "USInputCell.h"

@implementation USInputCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor mi_1_color];
    
    self.iconImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.iconImageView];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
    self.titleLabel.textColor = [UIColor labelColor];
    [self.contentView addSubview:self.titleLabel];
    
    self.inputField = [[UITextField alloc] init];
    self.inputField.font = [UIFont systemFontOfSize:16];
    self.inputField.textColor = [UIColor labelColor];
    self.inputField.textAlignment = NSTextAlignmentRight;
    self.inputField.placeholder = @"请输入";
    self.inputField.adjustsFontSizeToFitWidth = YES;
    [self.contentView addSubview:self.inputField];
    
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.centerY.equalTo(self.contentView);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImageView.mas_right).offset(8);
        make.centerY.equalTo(self.contentView);
    }];
    
    [self.inputField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.equalTo(self.contentView);
        make.left.greaterThanOrEqualTo(self.titleLabel.mas_right).offset(10);
        make.height.mas_equalTo(30);
    }];
}

- (void)configureWithTitle:(NSString *)title
                     image:(UIImage *)image
                 inputText:(NSString *)text {
    self.titleLabel.text = title;
    self.iconImageView.image = image;
    self.inputField.text = text;
}

@end
